GtkEntry: ellipsize placeholder text
authorJonh Wendell <jonh.wendell@intel.com>
Thu, 20 Jun 2013 17:39:28 +0000 (14:39 -0300)
committerJonh Wendell <jonh.wendell@intel.com>
Fri, 21 Jun 2013 12:29:15 +0000 (09:29 -0300)
The placeholder string is truncated when there's no
room for it in entry's width.

So, by ellipsizing it, the user can notice the text
was truncated so that they can workaround that by,
for example, maximizing the window.

https://bugzilla.gnome.org/show_bug.cgi?id=702763

gtk/gtkentry.c

index 8158c8168004671592fd1781cbbf2496891b156c..c4e601326a358534166e05093e91fe6ea5891830 100644 (file)
@@ -5987,6 +5987,7 @@ gtk_entry_create_layout (GtkEntry *entry,
       attr->start_index = 0;
       attr->end_index = G_MAXINT;
       pango_attr_list_insert (tmp_attrs, attr);
+      pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
     }
 
   if (preedit_length)
@@ -6127,6 +6128,9 @@ draw_text_with_color (GtkEntry *entry,
 
   get_layout_position (entry, &x, &y);
 
+  if (show_placeholder_text (entry))
+    pango_layout_set_width (layout, PANGO_SCALE * gdk_window_get_width (entry->priv->text_area));
+
   cairo_move_to (cr, x, y);
   gdk_cairo_set_source_rgba (cr, default_color);
   pango_cairo_show_layout (cr, layout);